package dao;

import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import dto.MemberDTO;
import dto.MessageDTO;

public class MessageDAO {
	private SqlMapClientTemplate sqlMap;
	public MessageDAO(SqlMapClientTemplate sqlMap) {
		this.sqlMap = sqlMap;
	}
	
	public void insertMessage(MessageDTO mto) {
		sqlMap.insert("insertMessage", mto);
	}
	
	public ArrayList selectAllMessage(HashMap map) {
		return (ArrayList) sqlMap.queryForList("selectAllMessage", map);
	}

	public ArrayList selectWriterMessageById(String member_id) {
		return (ArrayList) sqlMap.queryForList("selectWriterMessageById", member_id);
	}

	public ArrayList<MessageDTO> selectReaderMessageById(String member_id) {
		return (ArrayList) sqlMap.queryForList("selectReaderMessageById", member_id);

	}
	
	public MemberDTO selectWriterNameByMemberId(String member_id) {
		return (MemberDTO)sqlMap.queryForObject("selectWriterNameByMemberId", member_id);
	}
	
	public ArrayList selectSpecificMessageWAR(HashMap map) {
		return (ArrayList)sqlMap.queryForList("selectSpecificMessageByWAR", map);
	}

	public MemberDTO selectMemberInfoByRoomNo(int room_no) {
		return (MemberDTO)sqlMap.queryForObject("selectMemberByRoomNo", room_no);
	}
	
	public MemberDTO selectMemberIdByName(HashMap map) {
		return (MemberDTO)sqlMap.queryForObject("selectMemberIdByName", map);
	}
//	public RoomDTO selectRoomInfo(String )
}